package day8;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 * 题目链接
 * https://www.nowcoder.com/practice/839f681bf36c486fbcc5fcb977ffe432?tpId=85&&tqId=29844&rp=1&ru=/activity/oj&qru=/ta/2017test/question-ranking
 */

public class Main1 {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bufferedReader.readLine());
        String[] strings = new String[n];
        for (int i = 0; i < n; i++) {
            strings[i] = bufferedReader.readLine();
        }
        if(isDicSort(strings) && isLengthSort(strings)) System.out.println("both");
        else if(isLengthSort(strings)) System.out.println("lengths");
        else if(isDicSort(strings)) System.out.println("lexicographically");
        else System.out.println("none");

    }
    public static boolean isDicSort(String[] strings) {
        for (int i = 0; i < strings.length-1; i++) {
            //字典排序
            if(strings[i].compareTo(strings[i+1]) > 0) {
                return false;
            }
        }
        return true;
    }
    public static boolean isLengthSort(String[] strings) {
        for (int i = 0; i < strings.length-1; i++) {
            //长度排序
            if(strings[i].length() > strings[i+1].length()) {
                return false;
            }
        }
        return true;
    }
}